package com.vx.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.vx.service.IUserService;
import com.vx.vo.UserVO;

@Controller
@RequestMapping("/")
@SessionAttributes(value="user") 
public class LoginController {
	
	@Autowired
	private IUserService userService;
	
	static Logger logger=Logger.getLogger(LoginController.class.getName());
	
	@RequestMapping("/")
	public String loginindex(Model model){
		return "login"; 
	}
	
	/**
	 * 登录
	 */
	@RequestMapping("/login")
	public String login(String userCode,Model model){
		//2：使用用户名作为查询条件，查询员工表，获取当前用户名对应的信息
		UserVO user = userService.findUserByName(userCode);
		//3：将查询的对象（惟一）放置到Session中
		model.addAttribute("user", user);
		return "main";
	}
	
	@RequestMapping("/top")
	public String top(Model model){
		return "top"; 
	}
	
	@RequestMapping("/welcome")
	public String welcome(Model model){
		return "welcome"; 
	}
	
	@RequestMapping("/left")
	public String left(Model model){
		return "left"; 
	}
}
